using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;

namespace CodeStory.SmartUpload
{
	public class SmartProgressHttpHandler : IHttpHandler
	{
		#region IHttpHandler Members
		public bool IsReusable {
			get { return true; }
		}

		public void ProcessRequest(HttpContext context) {
			SmartUploadContext c = SmartUploadContext.GetContext(context);
			if (c != null) {
				StringBuilder sb = new StringBuilder();
				sb.Append("<script>\n\r<!--\n\r");
				sb.Append("var obj=");
				sb.Append(c.SmartProgress.ToString());
				sb.Append(";\n\r");
				sb.Append("//-->\n\r</script>");
				context.Response.Write(sb.ToString());
				context.Response.Flush();
				context.Response.Close();
			}
		}

		#endregion
	}
}
